package fn;

public class Ln extends Function {

	private Function[] child;

	private Ln(Function f) {
		child = new Function[] {
			f };
	}

	public static Function create(Function f) {
		return new Ln(f);
	}

	@Override
	protected Function[] child() {
		return child;
	}

	@Override
	public double evaluate(double sub) {
		return Math.log(child[0].evaluate(sub));
	}

	@Override
	public String prefix() {
		return "ln(";
	}

	@Override
	public String infix() {
		return "";
	}

	@Override
	public String postfix() {
		return ")";
	}

	@Override
	protected boolean withPar() {
		return true;
	}

	@Override
	protected int precedence() {
		return Integer.MAX_VALUE;
	}

	public Function derivative() {
		Function out = Divide.create(child[0].derivative(), child[0]);
		return out;
	}

}
